<?php
/*
+--------------------------------------------------------------------------
|   AffiliStore 2
|   ========================================
|   Web: http://www.affilistore.com
|   Email: admin (at) affilistore (dot) com
|	License Type: AffiliStore 2 is NOT open source software and limitations apply 
|   Licence Info: Visit AffiliStore website and click on 'Licence'
+--------------------------------------------------------------------------
*/
if (eregi(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) || eregi(".inc.php",$_SERVER['PHP_SELF'])) {
	echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";
	exit;
}

// get listing options		
$getListOptions = mysql_query("SELECT value FROM affiliSt_config WHERE name = 'prodListings'");
$listOptions = mysql_fetch_assoc($getListOptions);
$prodOptions = explode(":", $listOptions['value']);

// popular products listing
$getPopular = mysql_query("SELECT prodImageSmall, prodImageURL, prodName, merchantProdID, dbProdID, prodDB, prodPrice, prodCurrency, prodPopularity FROM affiliSt_products1 ORDER BY prodPopularity DESC LIMIT 0, 5");
$popularList = mysql_fetch_assoc($getPopular);

$box_content = new XTemplate ("skins/".$configSkin['value']."/styleTemplates/popularprod.tpl");

	do {
	
		// get titles
		$getTitles = mysql_query("SELECT value FROM affiliSt_config WHERE name = 'feedMemory".$popularList['prodDB']."'");
		$allTitles = mysql_fetch_assoc($getTitles);
		$listTitles = explode("-:-", $allTitles['value']);
		
		// thumb image
		if ($popularList['prodImageSmall'] == NULL) {
		$thumbImage = $popularList['prodImageURL'];
		} else {
		$thumbImage = $popularList['prodImageSmall'];
		}
	
		$popResult = ucwords(strtolower($popularList['prodName']));
		
					// use merchant product ids
					if ($navOpt[12] == 1) {
					$theprodID = $popularList['merchantProdID'];
					} else {
					$theprodID = $popularList['dbProdID'];
					}
					if ($navOpt[7] == 1) {
					// html perma
					$box_content->assign("LINKDATA",$installDir['value'].'product/'.$popularList['prodDB'].'/'.$theprodID.'/'.urltxt($popularList['prodName']).'.html');
					$box_content->assign("IMAGELINK",$installDir['value'].'img/'.$popularList['prodDB'].'/'.$popularList['dbProdID'].'.jpg');
					} else {
					// php link
					$box_content->assign("LINKDATA",$installDir['value'].'index.php?case=product&proddb='.$popularList['prodDB'].'&pid='.$theprodID);
					$box_content->assign("IMAGELINK",$thumbImage);
					}
					if ($prodOptions[6] == 1 && $popularList['prodPrice'] != '') {
						if ($prodOptions[12] == 1) {
						$theTitle = $listTitles[27];
						} else {
						$theTitle = '';
						}
						if ($popularList['prodPrice'] == 0.00) {
						$box_content->assign("PRICE",'<span class="popProdPrice">'.$theTitle.'N/A</span><br />');
						} else {
						$box_content->assign("PRICE",'<span class="popProdPrice">'.$theTitle.$popularList['prodCurrency'].$popularList['prodPrice'].'</span><br />');
						}
					} else {
					$box_content->assign("PRICE",'');
					}
			
					$box_content->assign("DATA",substr($popResult, 0, 30).'...');
					$box_content->assign("POPIMAGE",$popularList['dbProdID']);
					$box_content->parse("popularprod.li");
	
		} while ($popularList = mysql_fetch_assoc($getPopular));




$box_content->assign("DATA", "Popular Products");

$box_content->assign("SKIN",$configSkin['value']);
$box_content->parse("popularprod");
$box_content = $box_content->text("popularprod");
?>